//
//  markView.m
//  QoilPublic
//
//  Created by SunChao on 17/9/9.
//  Copyright © 2017年 杨凯. All rights reserved.
//

#import "MarkView.h"

@implementation MarkView
- (void)initWithFrame:(CGRect)frame {
    
    NSArray *arr = @[@"JAVA",@"C",@"C++",@"PHP",@"Object-C",@"Swift",@"JAVAWEB",@"C#",@"MYSQL"];
    NSInteger x = 10;
    NSInteger y = 100;
    
    for (NSInteger i=0; i<arr.count; i++) {
        NSString *str = [arr objectAtIndex:i];
        CGSize size = [str sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16.0f]}];
        
        if (x + size.width > self.frame.size.width-20) {
            x = 10;
            y = y + size.height+5; //5为两行之间的高度间隔
        }
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x, y, size.width, size.height)];
        label.text = str;
        label.font = [UIFont systemFontOfSize:16.0f];
        label.backgroundColor = [UIColor orangeColor];
        label.textColor = [UIColor whiteColor];
        [self addSubview:label];
        
        x = x + size.width +10; //10为两个标签之间的宽度间隔
    }
}

@end
